package com.core.framework.tools;

import com.core.log.Log;
import com.google.gson.Gson;
/**
 * Rule 架构工具类  不用于  应用项目开发  只用于架构
 * @author 刘涛
 * @since Jun 27, 2012
 */
public class Tools {
	
	public static Gson getGson()
	{
		return new Gson();
	}
    public static String toOntRowName(String voName) {
        StringBuffer sb = new StringBuffer(voName.length());
        boolean flag = false;
        for (int i = 0; i < voName.length(); i++) {
            char cur = voName.charAt(i);
            if (i == 0)
                cur = Character.toLowerCase(cur);
            if (cur == '_') {
                flag = true;
            } else {
                if (flag) {
                    sb.append(Character.toUpperCase(cur));
                    flag = false;
                } else {
                    sb.append(Character.toLowerCase(cur));
                }
            }
        }
        return sb.toString();
    }
	public static boolean getYesNo(String tags)
	{
		if(tags.toUpperCase().equals("YES"))
		{
			return true;
		}
		return false;
	}
	
	public static void main(String args[]) {
		Log.info(toInRowName("groupUserName").equals("GROUP_USER_NAME"));
        Log.debug(toOntRowName("GROUP_USER_NAME"));
        Log.debug(toSetOntRowName("GROUP_USER_NAME"));
        Log.debug(toGetOntRowName("GROUP_USER_NAME"));
        Log.debug(toGetOntRowName("groupUserName"));
    }
 
    public static String toInRowName(String voName) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < voName.length(); i++) {
            char cur = voName.charAt(i);
            if (Character.isUpperCase(cur)) {
                sb.append(cur);
            } else {
                sb.append(cur);
            }
        }
        return sb.toString().toUpperCase();
    }
    public static String toSetOntRowName(String voName) {
        StringBuffer sb = new StringBuffer();
        boolean flag = true;
        for (int i = 0; i < voName.length(); i++) {
            char cur = voName.charAt(i);
            if (cur == '_') {
                flag = true;
            }
            if (Character.isUpperCase(cur)) {
                sb.append(Character.toUpperCase(cur));
            } else {
                if (flag) {
                    sb.append(Character.toUpperCase(cur));
                    flag = false;
                } else {
                    sb.append(Character.toLowerCase(cur));
                }
            }
        }
        return "set" + sb.toString();
    }
    public static String toGetOntRowName(String voName) {
        StringBuffer sb = new StringBuffer();
        boolean flag = true;
        for (int i = 0; i < voName.length(); i++) {
            char cur = voName.charAt(i);
            if (cur == '_') {
                flag = true;
            }
            if (Character.isUpperCase(cur)) {
                sb.append(Character.toUpperCase(cur));
            } else {
                if (flag) {
                    sb.append(Character.toUpperCase(cur));
                    flag = false;
                } else {
                    sb.append(Character.toLowerCase(cur));
                }
            }
        }
        return "get" + sb.toString();
    }
}
